﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LPY.LeHealth.Service;
using System.Web.Mvc;
using LPY.LeHealth.DTO;
using LPY.LeHealth.WebSite.Common;

namespace LPY.LeHealth.WebSite.Controllers
{
    public class MVCController:Controller
    {
        PhysicalService physervice = new PhysicalService();
        OrderService orderservice = new OrderService();
        ComboService comboservice = new ComboService();

        /// <summary>
        /// 根据ID获取体检项目
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult tj_list_details_show(int id)
        {
            var d1 = physervice.GetcomTophy(id);
            return Json(d1);
        }

        /// <summary>
        /// 提交团检订单
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public int Add_tuanorder(int Sonnum, int Yusuan, string Uname, string Utell, string Tdate, int HospitalId, int Tstate)
        {
            if (orderservice.Add_tuanorder(Sonnum, Yusuan, Uname, Utell, Tdate, HospitalId, Tstate) >0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 根据id获取团检订单信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GettuanorderById(int id)
        {
            var d = orderservice.GettuanorderbyId(id);
            return Json(d,JsonRequestBehavior.DenyGet);
        }


        /// <summary>
        /// 获取订单功能（根据用户id，获取该用户订单信息）
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult my_order()
        {
            JsonMessage jm = new JsonMessage();
            //if (null == Session["user_id"])
            //{
            //    jm.Code = 0;
            //    jm.Msg = "session值为空，请解决该错误";
            //    return Json(jm);
            //}

            var id =2;//Convert.ToInt32(Session["user_id"]);

            jm.Code = 1;
            jm.Msg = "获取该用户的订单信息";
            jm.Data = orderservice.GetOrderList(id, 0);

            return Json(jm,JsonRequestBehavior.DenyGet);
        }

        /// <summary>
        /// 获取订单数
        /// </summary>
        /// <returns></returns>
        public ActionResult OrderCount()
        {
            var id = 2;//Convert.ToInt32(Session["user_id"]);
            return Json(orderservice.GetOrderCount(id));
        }

        /// <summary>
        ///  根据地区ID获取体检套餐列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetComboByAreaId(int id)
        {
            var d = comboservice.GetComboByArea(id);
            return Json(d);
        }
        /// <summary>
        /// 根据地区ID获取体检套餐的数目
        /// </summary>
        /// <returns></returns>
        public ActionResult GetComboByAreaIdCount(int id)
        {
            var d = comboservice.GetComboByAreaCount(id);
            return Json(d);
        }

        /// <summary>
        /// 显示前1条组合套餐数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetZuheCombo()
        {
            var d = comboservice.GetZuhe();
            return Json(d);
        }
    }
}